package pers.course.others;

import java.util.Scanner;

public class GCD {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        long a = in.nextLong();
        long b = in.nextLong();
        System.out.println(gcd(a, b));
    }
    public static long gcd(long a, long b) {
        return a % b == 0 ? b : gcd(b, a % b);
    }
}
